package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.system.domain.news.NewsPictureInfo;
import com.ruoyi.system.domain.news.query.NewsPictureInfoQuery;
import com.ruoyi.system.domain.news.vo.NewsPictureInfoVo;
import com.ruoyi.system.domain.news.vo.NewsPictureInfoVo;
import com.ruoyi.system.mapper.news.NewsPictureInfoMapper;
import com.ruoyi.system.service.news.NewsPictureInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsPictureInfoServiceImpl extends ServiceImpl<NewsPictureInfoMapper, NewsPictureInfo>
        implements NewsPictureInfoService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsPictureInfoVo> getNewsPictureInfoList(NewsPictureInfoQuery newsPictureInfoQuery) {
        if (newsPictureInfoQuery.getIfPage()) {
            PageHelper.startPage(newsPictureInfoQuery.getPageNum(), newsPictureInfoQuery.getPageSize());
        }
        List<NewsPictureInfoVo> newsPictureInfoVoList = baseMapper.getNewsPictureInfoList(newsPictureInfoQuery);
        if (!newsPictureInfoVoList.isEmpty() && newsPictureInfoQuery.getId() == null) {
            for (NewsPictureInfoVo newsPictureInfoVo:newsPictureInfoVoList) {
                newsPictureInfoVo.setContent(null);
            }
        }
        return newsPictureInfoVoList;
    }
}
